<template>
  <div class="share-exp">
    <div class="top-box">
      <div class="nav-bar">
        <div class="nav-left">
          <i
            class="iconfont icon-zuojiantou"
            @click="$router.push('/find')"
          ></i>
        </div>
        <div class="nav-title">面试技巧</div>
      </div>
      <div class="search-box" @click="$router.push('/searchshare')">
        <van-icon name="search" size="20" />
        请输入关键字
      </div>
    </div>
    <div class="experience-box">
      <div @click="$router.push(`/sharedetail/${item.id}`)" v-for="item in shareList" :key="item.id" class="experience-item">
        <div class="exp-title">{{ item.title }}</div>
        <div class="exp-text">{{ item.content }}</div>
        <div class="exp-user">
          <div class="head">
            <img :src="baseURL + item.author.avatar" alt="" />
            <span>{{ item.author.nickname }}</span>
          </div>
          <div class="time">
            {{ formatTime(item.created_at) }}
          </div>
          <div class="prev">
            <van-icon name="comment-o" size="17px" /><span>{{
              item.article_comments
            }}</span>
          </div>
          <div class="zan">
            <van-icon
              name="good-job-o"
              size="17px"
              :class="{ active: item.star != 0 }"
            /><span>{{ item.star }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="no-more">没有更多了</div>
  </div>
</template>

<script>
import { experienceList } from '@/api/skill'
export default {
  data () {
    return {
      shareList: []
    }
  },
  created () {
    this.loadExperienceList()
  },
  methods: {
    async loadExperienceList () {
      const res = await experienceList()
      console.log(res)
      this.shareList = res.data.list
      console.log(this.shareList)
    },
    formatTime (date) {
      return this.dayjs(date).format('YYYY.MM.DD')
    }
  }
}
</script>

<style lang="less" scoped>
.share-exp {
  .top-box {
    padding-bottom: 10px;
    padding-top: 5px;
    .nav-bar {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      height: 40px;
      line-height: 1.5;
      text-align: center;
      background-color: #fff;
      .nav-left {
        position: absolute;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        padding: 0 10px;
        .iconfont {
          font-size: 25px;
        }
      }
      .nav-title {
        margin: 0 auto;
        font-size: 18px;
      }
    }
    .search-box {
      margin: 5px auto;
      width: 350px;
      height: 30px;
      color: #b3b3b3;
      border-radius: 20px;
      background-color: #f7f4f5;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 15px;
    }
  }
  .experience-box {
    padding: 0 10px;
    background-color: #fff;
    .experience-item {
      padding-top: 15px;
      padding-bottom: 20px;
      text-align: left;
      border-bottom: 1px solid #f8f9f9;
      .exp-title {
        font-size: 16px;
        margin-bottom: 7px;
      }
      .exp-text {
        margin-top: 10px;
        margin-bottom: 15px;
        font-size: 14px;
        display: -webkit-box;
        text-overflow: ellipsis;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .exp-user {
        display: flex;
        align-items: center;
        font-size: 13px;
        color: #b4b4bd;
        .head {
          flex: 1;
          display: flex;
          align-items: center;
          img {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            margin-right: 10px;
          }
        }
        .time {
          margin-right: 30px;
        }
        .prev,
        .zan {
          display: flex;
          align-items: center;
          margin-left: 15px;
          .active {
            color: red;
          }
          span {
            margin-left: 10px;
          }
        }
      }
    }
  }
  .no-more {
    font-size: 14px;
    color: #a0a1a2;
    padding-bottom: 25px;
    padding-top: 10px;
  }
}
</style>
